import React from 'react'
import {Route,IndexRoute} from 'react-router'
import App from './containers/App'
import Welcome from './pages/welcome'

//首页
const home = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/home/home').default)
  }, 'home')
}
/*业务管理-大伽对接 */
const galdocking = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/business/galdocking').default)
  }, 'galdocking')
}
/*业务管理-用户反馈 */
const userfeedback = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/business/userfeedback').default)
  }, 'userfeedback')
}
/*业务管理-大伽申请 */
const greatgal = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/business/greatgal').default)
  }, 'greatgal')
}
/*业务管理-消息推送 */
const messagePush = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/business/messagePush').default)
  }, 'messagePush')
}
/*用户管理-注册用户 */
const registered = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/user/registered').default)
  }, 'registered')
}
/*用户管理-认证用户*/
const authentication = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/user/authentication').default)
  }, 'authentication')
}
/*用户管理-大咖用户*/
const master = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/user/master').default)
  }, 'master')
}
/*用户管理-企业永华*/
const company = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/user/company').default)
  }, 'company')
}
/*用户管理-黑名单*/
const blacklist = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/user/blacklist').default)
  }, 'blacklist')
}

/*社区管理-内容审核*/
const contentAudit = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/communityManage/contentAudit').default)
  }, 'contentAudit')
}
/*社区管理-帖子列表*/
const contentList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/communityManage/contentList').default)
  }, 'contentList')
}
/*社区管理-评论列表*/
const commentList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/communityManage/commentList').default)
  }, 'commentList')
}
/*社区管理-举报列表*/
const reportList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/communityManage/reportList').default)
  }, 'reportList')
}

/*素材管理-大咖报告*/
const masterReport = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/materialManage/masterReport').default)
  }, 'masterReport')
}
/*素材管理-大咖访谈*/
const masterInterview = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/materialManage/masterInterview').default)
  }, 'masterInterview')
}
/*素材管理-课堂列表*/
const classroomList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/materialManage/classroomList').default)
  }, 'classroomList')
}
/*素材管理-专题列表*/
const subjectList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/materialManage/subjectList').default)
  }, 'subjectList')
}
/*素材管理-素材列表*/
const materialList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/materialManage/materialList').default)
  }, 'materialList')
}

/*系统管理-管理用户*/
const adminuser = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/admin/adminuser').default)
  }, 'adminuser')
}
/*系统管理-角色管理*/
const rolelist= (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/admin/rolelist').default)
  }, 'rolelist')
}
/*系统管理-基础数据*/
const baseData= (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/admin/baseData').default)
  }, 'baseData')
}
/*系统管理-版本控制*/
const versionControl= (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/admin/versionControl').default)
  }, 'versionControl')
}

//行业视频
const IndustryVideo = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/industry/IndustryVideo').default)
  }, 'IndustryVideo')
}
//行业要闻
const IndustryNews = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/industry/IndustryNews').default)
  }, 'IndustryNews')
}
//广告位设置弹框
const AdIndustryhome = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/moduleManage/AdIndustryhome').default)
  }, 'AdIndustryhome')
}
//行业活动
const IndustryActivities = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/industry/IndustryActivities').default)
  }, 'IndustryActivities')
}

/*企业管理-行业协会*/
const industryAssociation = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/companyManage/industryAssociation').default)
  }, 'industryAssociation')
}
/*企业管理-陵园列表*/
const cemeteryList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/companyManage/cemeteryList').default)
  }, 'cemeteryList')
}
/*企业管理-殡仪馆列表*/
const funeralParlourList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/companyManage/funeralParlourList').default)
  }, 'funeralParlourList')
}
/*企业管理-公司列表*/
const companyList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/companyManage/companyList').default)
  }, 'companyList')
}
/*企业管理-需求广场*/
const demandSquare = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/companyManage/demandSquare').default)
  }, 'demandSquare')
}
/*企业管理-招聘广场*/
const employmentSquare = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/companyManage/employmentSquare').default)
  }, 'employmentSquare')
}
/*企业管理-国际机构*/
const internationalMachinery = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/companyManage/internationalMachinery').default)
  }, 'internationalMachinery')
}
// 登录
const Login = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./containers/App/login').default)
  }, 'login')
}
/*模块管理-广告位设置*/
const adset = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/moduleManage/adset').default)
  }, 'adset')
}
/*模块管理-排序列表*/
const priorityList = (location, cb) => {
  require.ensure([], require => {
    cb(null, require('./pages/moduleManage/priorityList').default)
  }, 'priorityList')
}
// // 表格列表
// const table = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/menu/table').default)
//   }, 'table')
// }
// // 表格列表
// const test = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/menu/test').default)
//   }, 'test')
// }
// // 表格列表
// const table1 = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/menu/table1').default)
//   }, 'table1')
// }

// // 表格列表
// const table2 = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/menu/table2').default)
//   }, 'table2')
// }

// // 表格列表
// const table3 = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/menu/table3').default)
//   }, 'table3')
// }

// // 图表
// const echarts = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/menu/echarts').default)
//   }, 'echarts')
// }

// // 测试
// const chat = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/chat').default)
//   }, 'chat')
// }
// // 编辑器
// const editor = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/menu/editor').default)
//   }, 'editor')
// }

// // kindEditor
// const kindEditor = (location, cb) => {
//   require.ensure([], require => {
//     cb(null, require('./pages/menu/kindEditor').default)
//   }, 'kindEditor')
// }


/* 进入路由的判断*/
function isLogin(nextState, replaceState) {
  const token = sessionStorage.getItem('token')
  if (!token) {
    replaceState('/login')
    // hashHistory.push('/login')
  }
}

const routes = (
  <Route>
    <Route path="/" component={App} onEnter={isLogin}>
      <IndexRoute component={Welcome} />
      <Route path="/home" getComponent={home} />
      <Route path="/AdIndustryhome(/:contentType)" getComponent={AdIndustryhome} />   
      {/* 用户管理 */}
      <Route path="/registered" getComponent={registered} />
      <Route path="/authentication" getComponent={authentication} />
      <Route path="/master" getComponent={master} />
      <Route path="/company" getComponent={company} />
      <Route path="/blacklist" getComponent={blacklist} />
      {/* 社区管理 */}
      <Route path="/contentAudit" getComponent={contentAudit} />
      <Route path="/contentList" getComponent={contentList} />
      <Route path="/commentList" getComponent={commentList} />
      <Route path="/reportList" getComponent={reportList} />

      {/* 素材管理 */}
      <Route path="/masterReport" getComponent={masterReport} />
      <Route path="/masterInterview" getComponent={masterInterview} />
      <Route path="/classroomList" getComponent={classroomList} />
      <Route path="/subjectList" getComponent={subjectList} />
      <Route path="/materialList" getComponent={materialList} />

      {/* 资讯管理 */}
      <Route path="/IndustryVideo" getComponent={IndustryVideo} />
      <Route path="/IndustryActivities" getComponent={IndustryActivities} />
      <Route path="/IndustryNews" getComponent={IndustryNews} />
      {/* 系统管理 */}
      <Route path="/adminuser" getComponent={adminuser} />
      <Route path="/rolelist" getComponent={rolelist} />
      <Route path="/baseData" getComponent={baseData} />
      <Route path="/versionControl" getComponent={versionControl} />
      {/* 业务管理 */}
      <Route path="/galdocking" getComponent={galdocking} />
      <Route path="/userfeedback" getComponent={userfeedback} />
      <Route path="/greatgal" getComponent={greatgal} />
      <Route path="/messagePush" getComponent={messagePush} />
      {/* 企业管理 */}
      <Route path="/industryAssociation" getComponent={industryAssociation} />
      <Route path="/cemeteryList" getComponent={cemeteryList} />
      <Route path="/funeralParlourList" getComponent={funeralParlourList} />
      <Route path="/companyList" getComponent={companyList} />
      <Route path="/demandSquare" getComponent={demandSquare} />
      <Route path="/employmentSquare" getComponent={employmentSquare} />
      <Route path="/internationalMachinery" getComponent={internationalMachinery} />
      {/* 模块管理 */}
      <Route path="/adset" getComponent={adset} />
      <Route path="/priorityList" getComponent={priorityList} />
    </Route>
    <Route path="/login" getComponent={Login} />
  </Route>
);
export default routes
